package com.mrkun.vueshop.mapper;

import com.mrkun.vueshop.model.Fund;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author by yong
 * @date 2020/3/16
 */
@Mapper
public interface FundMapper {

    @Select("select id,manager_name,company,DATE_FORMAT(create_date,'%Y-%m-%e') createDate," +
            "registered_capital,type,name" +
            " from fund where name like #{query}")
    List<Fund> findAll(@Param("query") String query);

    @Select("select id,manager_name,company,DATE_FORMAT(create_date,'%Y-%m-%e') createDate," +
            "registered_capital,type,name" +
            " from fund where id = #{id}")
    Fund findOne(@Param("id")Integer id);

    @Insert("insert into fund (manager_name,company,create_date,registered_capital,type,name) " +
            "values(#{managerName},#{company},#{createDate},#{registeredCapital},#{type},#{name})")
    void addFund(Fund fund);

    @Select("select count(0) from fund")
    Integer count();


    @Update("update fund set manager_name=#{managerName},company=#{company},registered_capital=#{registeredCapital}," +
            "type=#{type},name=#{name} where id = #{id}")
    void update(Fund fund);

    @Delete("delete from fund where id = #{id}")
    void delete(@Param("id") Integer id);
}
